<?php

namespace backend\models;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "{{%jjr_project_house}}".
 *
 * @property string $id
 * @property int $project_id 项目ID
 * @property string $name 户型名称
 * @property int $main_pic 户型主图
 * @property string $description 户型描述
 * @property string $type 户型类型
 * @property int $area 户型面积
 * @property string $create_time 创建时间
 * @property string $update_time 更新疏忽
 * @property int $status 状态
 * @property string $management_type 物业类型
 * @property  string $struct 户型结构
 * @property  string $direction 朝向
 * @property  string $deal_limit 最早交收
 * @property  string $open_limit  最早开盘
 * @property  string $advantage 优势
 * @property  int $price 价格
 */
class JjrProjectHouse extends \common\core\BaseActiveRecord
{


    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%jjr_project_house}}';
    }
    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                    # 创建之前
                    \yii\db\ActiveRecord::EVENT_BEFORE_INSERT => ['create_time', 'update_time'],
                    # 修改之前
                    \yii\db\ActiveRecord::EVENT_BEFORE_UPDATE => ['update_time']
                ],
                #设置默认值
                'value' =>date('Y-m-d H:i:s')
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['jjr_project_id', 'name','main_pic','description','type'], 'required'],
            [['jjr_project_id', 'main_pic','price'], 'integer'],
            ['area','compare', 'compareValue' => 0, 'operator' => '>'],
            [['name'], 'string', 'max' => 50],
            //['type','string','length' => [1,1],'message'=>'请选择户型'],
            [['description','type','management_type','struct','direction','deal_limit','open_limit','advantage'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'jjr_project_id' => '项目ID',
            'create_time'=>'创建时间',
            'name' => '户型名称',
            'main_pic' => '户型主图',
            'description' => '户型描述',
            'area' => '户型大小（单位/平方米）',
            'type' => '户型类型',
            'management_type'=>'物业类型',
            'struct' =>'户型结构',
            'direction'=>'朝向',
            'deal_limit'=>'最早成交',
            'open_limit'=>'最早开盘',
            'advantage'=>'优势',
            'price'=>'价格'
        ];
    }
}
